package cn.antblog.code;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author yangjy
 * @version 1.0
 * @description: BDI上的日期操作
 * @date 2022/5/9 09:31
 */
public class DateBDI {

    public static void main(String[] args) {
        DateTimeFormatter yyyy_MM_dd = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd");
        DateTimeFormatter yyyyMM = DateTimeFormatter.ofPattern("yyyyMM");
        DateTimeFormatter dd = DateTimeFormatter.ofPattern("dd");
        LocalDate of27 = LocalDate.parse("20220327", yyyyMMdd);
        LocalDate of = of27.minusDays(1);
        //timest 日期
        String timest = of.format(yyyy_MM_dd);
        System.out.println("timest = " + timest);
        //date_id
        String date_id = of.format(yyyyMMdd);
        System.out.println("date_id = " + date_id);
        //curr_month_id
        String curr_month_id = of.format(yyyyMM);
        System.out.println("curr_month_id = " + curr_month_id);
        //curr_day
        String curr_day = of.format(dd);
        System.out.println("curr_day = " + curr_day);
        //last_month_id 上个月 月份 202202
        LocalDate last_date_month = of.minusMonths(1);
        String last_month_id = last_date_month.format(yyyyMM);
        System.out.println("last_month_id = " + last_month_id);

    }
}
